package com.kaibes.orm.curd;

import java.io.Serializable;
import java.util.List;

@SuppressWarnings("serial")
public class Select extends Wrapper implements Serializable {
    
    private boolean counted;
    private List<String> columns;
    private List<Query> queries;
    private List<String> orders;
    private List<OrderType> types;
    private long offset;
    private int size;
    
    public boolean isCounted() {
        return counted;
    }
    public Select setCounted(boolean counted) {
        this.counted = counted;
        return this;
    }
    public List<String> getColumns() {
        return columns;
    }
    public void setColumns(List<String> columns) {
        this.columns = columns;
    }
    public List<Query> getQueries() {
        return queries;
    }
    public void setQueries(List<Query> queries) {
        this.queries = queries;
    }
    public List<String> getOrders() {
        return orders;
    }
    public void setOrders(List<String> orders) {
        this.orders = orders;
    }
    public List<OrderType> getTypes() {
        return types;
    }
    public void setTypes(List<OrderType> types) {
        this.types = types;
    }
    public long getOffset() {
        return offset;
    }
    public void setOffset(long offset) {
        this.offset = offset;
    }
    public int getSize() {
        return size;
    }
    public void setSize(int size) {
        this.size = size;
    }
    
    @Override
    public int hashCode() {
        final int prime = 31;
        int result = 1;
        result = prime * result + ((columns == null) ? 0 : columns.hashCode());
        result = prime * result + (counted ? 1231 : 1237);
        result = prime * result + (int) (offset ^ (offset >>> 32));
        result = prime * result + ((orders == null) ? 0 : orders.hashCode());
        result = prime * result + ((queries == null) ? 0 : queries.hashCode());
        result = prime * result + size;
        result = prime * result + ((tableName == null) ? 0 : tableName.hashCode());
        result = prime * result + ((types == null) ? 0 : types.hashCode());
        return result;
    }
    
    @Override
    public boolean equals(Object obj) {
        if (this == obj)
            return true;
        if (obj == null)
            return false;
        if (getClass() != obj.getClass())
            return false;
        Select other = (Select) obj;
        if (columns == null) {
            if (other.columns != null)
                return false;
        } else if (!columns.equals(other.columns))
            return false;
        if (counted != other.counted)
            return false;
        if (offset != other.offset)
            return false;
        if (orders == null) {
            if (other.orders != null)
                return false;
        } else if (!orders.equals(other.orders))
            return false;
        if (queries == null) {
            if (other.queries != null)
                return false;
        } else if (!queries.equals(other.queries))
            return false;
        if (size != other.size)
            return false;
        if (tableName == null) {
            if (other.tableName != null)
                return false;
        } else if (!tableName.equals(other.tableName))
            return false;
        if (types == null) {
            if (other.types != null)
                return false;
        } else if (!types.equals(other.types))
            return false;
        return true;
    }
    
    @Override
    public String toString() {
        return "Select [tableName=" + tableName + ", counted=" + counted + ", columns=" + columns + ", queries="
                + queries + ", orders=" + orders + ", types=" + types + ", offset=" + offset + ", size=" + size + "]";
    }
    
}
